<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>监管者登录 - FinData管理系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        body {
            background-color: #f8f9fa;
            padding-top: 40px;
            padding-bottom: 40px;
        }
        .login-container {
            max-width: 400px;
            padding: 15px;
            margin: 0 auto;
        }
        .form-signin {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .form-signin .form-floating {
            margin-bottom: 10px;
        }
        .btn-danger {
            background-color: #dc3545;
            border-color: #dc3545;
        }
        .btn-danger:hover {
            background-color: #c82333;
            border-color: #bd2130;
        }
        .logo {
            text-align: center;
            margin-bottom: 20px;
        }
        .logo h1 {
            color: #dc3545;
            font-weight: bold;
        }
        .error-message {
            color: #dc3545;
            margin-top: 10px;
            display: none;
        }
    </style>
</head>
<body>
    <div class="container login-container">
        <div class="logo">
            <h1>FinData</h1>
            <p class="text-muted">监管者系统</p>
        </div>
        <div class="form-signin">
            <h2 class="mb-3 text-center">监管者登录</h2>
            <form id="loginForm">
                <div class="form-floating">
                    <input type="text" class="form-control" id="username" name="username" placeholder="用户名" required>
                    <label for="username">用户名</label>
                </div>
                <div class="form-floating">
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码" required>
                    <label for="password">密码</label>
                </div>
                <button class="w-100 btn btn-lg btn-danger mt-3" type="submit">登录</button>
                <div class="error-message mt-3" id="errorMessage"></div>
            </form>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.getElementById('loginForm').addEventListener('submit', async function(e) {
            e.preventDefault();
            
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const errorMessage = document.getElementById('errorMessage');
            
            try {
                const response = await fetch('/api/supervisor/login', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                    },
                    body: new URLSearchParams({
                        username: username,
                        password: password
                    })
                });
                
                const data = await response.json();
                
                if (response.ok) {
                    // 登录成功，跳转到监管者仪表盘
                    window.location.href = '/supervisor/dashboard';
                } else {
                    // 显示错误信息
                    const errorText = data.detail || '登录失败，请检查用户名和密码';
                    errorMessage.textContent = errorText;
                    errorMessage.style.display = 'block';
                }
            } catch (error) {
                console.error('登录请求失败:', error);
                const errorText = '登录请求失败，请稍后再试';
                errorMessage.textContent = errorText;
                errorMessage.style.display = 'block';
            }
        });
    </script>
</body>
</html> 